/**
 * 班次
 */
import { axios } from '@/utils/request';
// const hardcodeUrl = 'http://172.28.101.183:8087';

const hardcodeUrl = '';

const api = {
  shiftList: hardcodeUrl + '/user/shift/list',
  shift: hardcodeUrl + '/user/shift',
  planTypeList: hardcodeUrl + '/user/shift/plan-type/list',
  planType: hardcodeUrl + '/user/shift/plan-type',
  shiftFieldValidate: hardcodeUrl + '/user/shift/validate-field',
  planTypeFieldValidate: hardcodeUrl + '/user/shift/plan-type/validate-field',
  shiftsConfig: hardcodeUrl + '/user/shifts-config'
};

/**
 * 获取班次列表
 */
export function getShifts(params) {
  return axios({
    url: api.shiftList,
    method: 'get',
    params
  });
}

/**
 * 创建班次
 * @param {*} data
 */
export function createShift(data) {
  return axios({
    url: api.shift,
    method: 'post',
    data
  });
}

/**
 * 编辑班次
 * @param {*} data
 */
export function updateShift(data) {
  return axios({
    url: api.shift,
    method: 'put',
    data
  });
}

/**
 * 删除班次
 * @param {*} params
 */
export function deleteShift(params) {
  return axios({
    url: api.shift,
    method: 'delete',
    params
  });
}

/**
 * 获取计划停机类型列表
 */
export function getPlanTypes() {
  return axios({
    url: api.planTypeList,
    method: 'get'
  });
}

/**
 * 创建计划停机类型
 * @param {*} params
 */
export function createPlanType(data) {
  return axios({
    url: api.planType,
    method: 'post',
    data
  });
}

/**
 * 删除计划停机类型
 * @param {*} params
 */
export function deletePlanType(params) {
  return axios({
    url: api.planType,
    method: 'delete',
    params
  });
}

/**
 * 班次表单字段验证
 * @param {*} params
 */
export function validateShiftField(params) {
  return axios({
    url: api.shiftFieldValidate,
    method: 'get',
    headers: { validate: true },
    params
  });
}

/**
 * 计划停机类型表单字段验证
 * @param {*} params
 */
export function validatePlanTypeField(params) {
  return axios({
    url: api.planTypeFieldValidate,
    method: 'get',
    headers: { validate: true },
    params
  });
}
/**
 * 获取用户工作时间设置列表
 * @param {*} params
 */
export function getUserShiftConfig(params) {
  return axios({
    url: api.shiftsConfig + '/list',
    method: 'get',
    params
  });
}

/**
 * 创建用户工作时间设置
 * @param {*} data
 */
export function createUserShiftConfig(data) {
  return axios({
    url: api.shiftsConfig,
    method: 'post',
    data
  });
}

/**
 * 修改用户工作时间设置
 * @param {*} data
 */
export function updateUserShiftConfig(data) {
  return axios({
    url: api.shiftsConfig,
    method: 'put',
    data
  });
}

/**
 * 删除用户工作时间设置
 * @param {*} params
 */
export function deleteUserShiftConfig(params) {
  return axios({
    url: api.shiftsConfig,
    method: 'delete',
    params
  });
}

/**
 * 设置用户工作时间设置为默认
 * @param {*} data
 */
export function setUserShiftConfigDefault(data) {
  return axios({
    url: api.shiftsConfig + '/change',
    method: 'put',
    data
  });
}

/**
 * 验证用户工作时间设置的字段
 * @param {*} params
 */
export function validateUserShiftConfigPropertyField(params) {
  return axios({
    url: api.shiftsConfig + '/validate-field',
    method: 'get',
    headers: { validate: true },
    params
  });
}
